package com.dreamtour.mapper;

import com.dreamtour.entity.Posts;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author xls
 * @since 2024-12-24
 */
public interface PostsMapper extends BaseMapper<Posts> {
    @Select("SELECT " +
            "DATE_FORMAT(postTime, '%Y-%m-%d') as post_date, " +
            "COUNT(*) as count " +
            "FROM posts " +
            "WHERE postTime >= DATE_SUB(CURDATE(), INTERVAL 1 MONTH) " +
            "GROUP BY post_date " +
            "ORDER BY post_date ASC")
    List<Map<String, Object>> getDailyPosts();
}
